package com.zx.sercurity;

import android.content.Context;
import android.os.Build;

public class EmulatorRisk implements RiskControlInterface<RiskResult.EmulatorRiskResult> {

    private static final String TAG = EmulatorRisk.class.getSimpleName();
    @Override
    public RiskResult.EmulatorRiskResult riskCheck(Context context) {
        return isEmulator() ? new RiskResult.EmulatorRiskResult(true) : new RiskResult.EmulatorRiskResult(false);
    }

    /**
     * 是否是模拟器
     * @return
     */
    public boolean isEmulator() {
        return Build.FINGERPRINT.startsWith("generic")
                || Build.FINGERPRINT.startsWith("unknown")
                || Build.MODEL.contains("google_sdk")
                || Build.MODEL.contains("Emulator")
                || Build.MODEL.contains("Android SDK built for x86")
                || Build.MANUFACTURER.contains("Genymotion")
                || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
                || "google_sdk".equals(Build.PRODUCT)
                || Build.HARDWARE.contains("goldfish")
                || Build.HARDWARE.contains("ranchu");
    }

}
